import {StrictMode, Suspense} from "react";
import ReactDOM from "react-dom/client";
import {RouterProvider} from "react-router-dom";
import {ConfigProvider, Spin} from "antd";
import zhCN from "antd/locale/zh_CN";
import routes from "@/router/router";

const Layout = () => (
    <ConfigProvider locale={zhCN}>
        <Suspense fallback={<Spin style={{flex: 1}} />}>
            <RouterProvider router={routes} />
        </Suspense>
    </ConfigProvider>
);

const dev = process.env.NODE_ENV === "development";
const root = document.getElementById("root");

if (dev) {
    ReactDOM.createRoot(root).render(<Layout />);
} else {
    ReactDOM.createRoot(root).render(
        <StrictMode>
            <Layout />
        </StrictMode>
    );
}
